<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 将数组的每一项进行字符串拼接

        var arr = [3, 4, 6, 1, 3];

        // 输出：3, 4, 6, 1, 3
        // var str = "";
        // for (var i = 0; i < arr.length; i++) {
        //     str += arr[i];
        //     if (i < arr.length - 1) {
        //         str += ",";
        //     }
        // }

        // 数组.join(分隔符)，该函数返回一个字符串
        var str = arr.join(",");
        console.log(str);
    </script>
</body>

</html>